package com.ruoyi.stock2.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ruoyi.stock2.domain.TradeDataAndForetell;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.stock2.domain.TRADEDATA200;
import com.ruoyi.stock2.service.ITRADEDATA200Service;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 交易数据Controller
 * 
 * @author ruoyi
 * @date 2019-12-12
 */
@Controller
@RequestMapping("/stock2/TRADEDATA200")
public class TRADEDATA200Controller extends BaseController
{
    private String prefix = "stock2/TRADEDATA200";

    @Autowired
    private ITRADEDATA200Service tRADEDATA200Service;

    @RequiresPermissions("stock2:TRADEDATA200:view")
    @GetMapping()
    public String TRADEDATA200()
    {
        return prefix + "/TRADEDATA200";
    }

    /**
     * 查询交易数据列表
     */
    @RequiresPermissions("stock2:TRADEDATA200:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TRADEDATA200 tRADEDATA200)
    {
        startPage();
        List<TRADEDATA200> list = tRADEDATA200Service.selectTRADEDATA200List(tRADEDATA200);
        return getDataTable(list);
    }

    @RequiresPermissions("stock2:TRADEDATA200:list")
    @PostMapping("/getForetellData")
    @ResponseBody
    public TableDataInfo getForetellData(TRADEDATA200 tRADEDATA200)
    {
        Map a = new HashMap();
        a.put("symbol", tRADEDATA200.getSymbol());
        List<TradeDataAndForetell> list = tRADEDATA200Service.getForetellData(a);
        return getDataTable(list);
    }

    /**
     * 导出交易数据列表
     */
    @RequiresPermissions("stock2:TRADEDATA200:export")
    @Log(title = "交易数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TRADEDATA200 tRADEDATA200)
    {
        List<TRADEDATA200> list = tRADEDATA200Service.selectTRADEDATA200List(tRADEDATA200);
        ExcelUtil<TRADEDATA200> util = new ExcelUtil<TRADEDATA200>(TRADEDATA200.class);
        return util.exportExcel(list, "TRADEDATA200");
    }

    /**
     * 新增交易数据
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存交易数据
     */
    @RequiresPermissions("stock2:TRADEDATA200:add")
    @Log(title = "交易数据", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TRADEDATA200 tRADEDATA200)
    {
        return toAjax(tRADEDATA200Service.insertTRADEDATA200(tRADEDATA200));
    }

    /**
     * 修改交易数据
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TRADEDATA200 tRADEDATA200 = tRADEDATA200Service.selectTRADEDATA200ById(id);
        mmap.put("tRADEDATA200", tRADEDATA200);
        return prefix + "/edit";
    }

    /**
     * 修改保存交易数据
     */
    @RequiresPermissions("stock2:TRADEDATA200:edit")
    @Log(title = "交易数据", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TRADEDATA200 tRADEDATA200)
    {
        return toAjax(tRADEDATA200Service.updateTRADEDATA200(tRADEDATA200));
    }

    /**
     * 删除交易数据
     */
    @RequiresPermissions("stock2:TRADEDATA200:remove")
    @Log(title = "交易数据", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tRADEDATA200Service.deleteTRADEDATA200ByIds(ids));
    }
}
